<?php
// +----------------------------------------------------------------------
// | sfadmin - Suifeng Administration
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2020 http://suifeng.tech All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: suifeng <1787585212@qq.com>
// +----------------------------------------------------------------------

namespace suifeng\builder\form\control;

use suifeng\builder\form\Control;
use suifeng\helper\HtmlHelper;

class Text extends Control
{
    /**
     * 构造方法。
     *
     * @param array $config
     */
    public function __construct($name, $config = array())
    {
        parent::__construct($name, $config);

        $this->attributes['type'] = 'text';

        if (empty($this->attributes['class'])) {
            $this->attributes['class'] = 'form-control input sf-control sf-input-text';
        }
    }

    /**
     * 输出HTML。
     *
     * @return string
     */
    protected function _render_core()
    {
        $attributes = $this->attributes;
        $attributes['name'] = $this->_get_formatted_name();
        $attributes['value'] = $this->_get_formatted_value();

        $html = HtmlHelper::render_tag('input', $attributes);

        return $html;
    }
}

?>
